#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project : python的学习
@File    : 正则表达式.py
@IDE     : PyCharm
@Author  : 春风十里
@Date    : 2023/6/27 15:24

'''
# 导入re模块
import re

a = "abc123+-*"
b = re.findall('abc', a)
print(b)
s = "a123456b"
rule = "a[0-9][1-6][1-6][1-6][1-6][1-6]b"
l = re.findall(rule, s)
print(l)
s = "abcabcaccaac"
rule = "a[a,b,c]c"
l = re.findall(rule, s)
print(l)
print(re.findall("caa[a,^]", "caa^bcabcaabc"))
print(re.findall("caa[^,a]", "caa^bcabcaabc"))
print(re.findall("^abca", "abcabcabc"))
print(re.findall("abc$", "abcabcabc"))
print(re.findall("c\d\d\da", "abc123abc"))
print(re.findall("\^abc", "^abc^abc"))
print(re.findall("\s\s", "a c"))
print(re.findall("\w\w\w", "abc12_"))
print(re.findall("\w{2}", "abc12_"))
print(re.findall("\w{2}", "abc12_"))
print(re.findall("010-\d*", "010-123456789"))
print(re.findall("010-\d+", "010-123456789"))
print(re.findall(".", "010\n?!"))
print(re.findall("010-\d?", "010-123456789"))
print(re.findall("010-\d*", "010-123456789"))
print(re.findall("010-\d*?", "010-123456789"))
print(re.findall("010-\d{3,5}", "010-123456789"))
print(re.findall("010-\d{3,5}?", "010-123456789"))
s = "010-123456789"
rule = "010-\d*"
rule_complie = re.compile(rule)
print(rule_complie)
s_complie = rule_complie.findall(s)
print(s_complie)
s = "010-123456789"
rule = "010-\d*"
rule_complie = re.compile(rule)
s_complie = rule_complie.match(s)
print(s_complie)
s = "010-123456789"
rule = "010-\d*"
rule_complie = re.compile(rule)
s_complie = rule_complie.match(s)
print(s_complie.span())
s = "abcabcacc"
l = re.sub("abc","ddd",s)
print(l)
s = "abcabcacc"
l = re.subn("abc","ddd",s)
print(l)
s = "abcabcacc"
l = re.split("b",s)
print(l)
